// 记录当前system操作数据
const state = {
  collapsed: localStorage.getItem('collapsed') ? JSON.parse(localStorage.getItem('collapsed')) : false, // 菜单栏的缩放
  defaultSelectedKeys: localStorage.getItem('defaultSelectedKeys') ? JSON.parse(localStorage.getItem('defaultSelectedKeys')) : [], // 初始选中菜单key的数组
  defaultOpenKeys: localStorage.getItem('defaultOpenKeys') ? JSON.parse(localStorage.getItem('defaultOpenKeys')) : [] // 初始展开的submenu 菜单项的数组
}

const mutations = {
  changeCollapsed (state) {
    state.collapsed = !state.collapsed
    localStorage.setItem('collapsed', state.collapsed)
  },
  changeSelectedKeys (state, payload) {
    state.defaultSelectedKeys = payload
    localStorage.setItem('defaultSelectedKeys', JSON.stringify(payload))
  },
  changeOpenKeys (state, payload) {
    state.defaultOpenKeys = payload
    localStorage.setItem('defaultOpenKeys', JSON.stringify(payload))
  }
}
export default {
  state,
  mutations
}
